home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 16865 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  786 b 

  1. Path: morse.ukonline.co.uk!usenet
  2. From: andy.walsh@ukonline.co.uk
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Dynamically allocating 2-dim arrays
  5. Date: 9 Apr 1996 14:24:26 GMT
  6. Organization: UK Online
  7. Message-ID: <4kdruq$6kg@morse.ukonline.co.uk>
  8. References: <4k47ii$ppa@galaxy.ucr.edu>
  9. NNTP-Posting-Host: wwwproxy.ukonline.co.uk
  10.  
  11. I think if memory serves it is something like this:-
  12.  
  13.                       float far* far* image;
  14.  
  15.     image = new float far* [WIDTH];
  16.     for (i=0; i < LENGTH; i++)
  17.         image[i] = new float far [WIDTH];
  18.  
  19.  
  20. Just replace float with int.  With two dimension arrays you have to
  21. allocate 1D then allocate each of them in a loop (You have to do the
  22. same for deleting them too):-
  23.  
  24. for (i=0; i < LENGTH; i++)
  25.     delete[] image[i];
  26.  
  27. delete[] image;
  28.  
  29. Hope this helps.
  30.  
  31. Andy Walsh
  32.